package vivek.project.pocketmoney.common.logger
{
	import mx.logging.ILogger;
	import mx.logging.Log;
	import mx.logging.LogEventLevel;

	public class InvestmentLogger
	{
		private static var logger:ILogger=null;
		private static var logs:Array=new Array();
		private static const messageTemplate:String="{0}\t{1}\t{2}\t{3}\t{4}\t{5}";
		private static var pmTarget:PMLogTarget=new PMLogTarget();

		public static function flush():int
		{
			var count:int=0;
			var obj:Object=new Object();
			if (logger == null)
			{
				logger=Log.getLogger("vivek.project.pocketmoney");
				Log.addTarget(new PMLogTarget());
				pmTarget.filters["vivek.project.pocketmoney.*"];
			}
			for each (obj in logs)
			{
				logRecord("INVESTMENT", obj.message, obj);
				count++;
			}
			logs.splice(0, count);
			return count;
		}

		public static function logMultiple(investObj:Object):void
		{
			logs.push(investObj);
		}

		public static function logRecord(module:String, shortMessage:String, object:Object):void
		{
			if (logger == null)
			{
				logger=Log.getLogger("vivek.project.pocketmoney");
				Log.addTarget(new PMLogTarget());
				pmTarget.filters["vivek.project.pocketmoney.*"];
			}
			var details:String=object.amount + "\t" + object.account + "\t" + object.date + "\t" + object.transferAccount + "\t" + object.memo;
			//	logger.log(LogEventLevel.INFO, messageTemplate, object.randomId, "INVESTMENT", shortMessage, details);
		}

		public function InvestmentLogger()
		{
			super();
		}
	}
}